package com.axxc.jpa.task.rabbitmsg.receiver;

import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.alibaba.fastjson.JSONObject;
import com.axxc.jpa.entity.DeadLetterMsgEntity;
import com.axxc.jpa.out.common.constant.RabbitMQConstant;

/**
 * @ClassName: RabbitMqReceiver
 * @Description: 死信队列消费者,到期后再转发
 * @author xxc
 * @date 2018年8月28日22:28:46
 * @see http://47.98.248.215:15672/#/
 */
@Component
@RabbitListener(queues = RabbitMQConstant.DEFAULT_REPEAT_TRADE_QUEUE_NAME)
public class RabbitMqDeadTradeStringMsgReceiver {

	@Autowired
	private AmqpTemplate rabbitTemplate;

	@RabbitHandler
	public void processA(String msg) {

		DeadLetterMsgEntity<?> entity = JSONObject.parseObject(msg, DeadLetterMsgEntity.class);
		this.rabbitTemplate.convertAndSend(entity.getQueueName(), entity.getContent());

	}
}
